#ifndef PCRCHARTITEM_H
#define PCRCHARTITEM_H

#include <QChart>
#include <QChartView>
#include <QSharedPointer>
#include <QSplineSeries>
#include <QScatterSeries>
#include <QLineSeries>
#include <QValueAxis>
#include <QRegularExpression>
#include <QHBoxLayout>
#include <QTime>
#include <QDebug>
#include <QLegend>
#include <QLegendMarker>
#include "pcrState.h"

using namespace QtCharts;

class PCRChartItem : public QChart
{

public:
    enum ShowState{
        NORM,
        HIDE,
        BOLD
    };

    Q_OBJECT
public:
    PCRChartItem(QWidget *parent = nullptr);

    void appendCurve(QString name, QVector<QPointF> pointList, QString type, ShowState state=NORM);

    void changeCurveState(QString name, ShowState state);
    void changeCurveState(const QStringList &names, ShowState state);
    void changeCurveState_reg(QString name, ShowState state);

    void updateCurve();
    void updateRange();
    void updateRange(double xmin, double xmax, double ymin, double ymax);

private:

    QPen getPen(QString name, ShowState state = NORM);

    QValueAxis* _axisX;
    QValueAxis* _axisY;

    QMap<QString, QXYSeries*>       _series;
    QMap<QString, ShowState>        _lastState;
    QMap<QString, ShowState>        _state;

//    QMap<ChannelName, double>       _rangeMax;      // 每个通道单独设置一个range
//    QMap<ChannelName, double>       _rangeMin;

    double      _xmin = 100000;
    double      _xmax = 0;
    double      _ymin = 100000;
    double      _ymax = 0;

};

#endif // PCRCHARTITEM_H
